// Licensed under the Apache License, Version 2.0 (the "License");
// you may not use this file except in compliance with the License.
// You may obtain a copy of the License at
//
//     http://www.apache.org/licenses/LICENSE-2.0
//
// Unless required by applicable law or agreed to in writing, software
// distributed under the License is distributed on an "AS IS" BASIS,
// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
// See the License for the specific language governing permissions and
// limitations under the License.
//
// Author: wsfuyibing <682805@qq.com>
// Date: 2024-12-02

package add

import (
	"gitee.com/go-libs/perm"
	"gomq/app"
	// "gomq/app/perm"
)

type Request struct {
	ApplicationId any             `json:"application_id" validate:"required,min=1" label:"Application site"`
	ParentId      any             `json:"parent_id" validate:"omitempty,min=0" label:"Parent resource"`
	Permission    perm.Permission `json:"permission" validate:"required,min=2,max=30" label:"Permission symbol"`
	Kind          any             `json:"kind" validate:"required,min=1,max=3" label:"Resource kind"`
	// Path          perm.Path       `json:"path" validate:"required,min=1,max=255" label:"Resource path"`
	Label string `json:"label" validate:"required,min=2,max=90" label:"Resource name"`
	Sort  any    `json:"sort" validate:"omitempty,min=0,max=9999" label:"Resource sort"`
}

func (o *Request) BeforeValidate() (err error) {
	o.ApplicationId = app.AnyInt(o.ApplicationId, 0)
	o.ParentId = app.AnyInt(o.ParentId, 0)
	o.Kind = app.AnyInt(o.Kind, 0)
	o.Sort = app.AnyInt(o.Sort, 0)
	return
}
